* Code replication MASTER do-file for "Voluntary Minimum Wages: The Local Labor Market Effects of National Retailer Policies" by Ellora Derenoncourt and David Weil

*First created: 2/19/2025
*Last updtated: 2/19/2025
*Outline: 	#0-Set preliminaries
*			#1-Build: Builds analysis datasets
*			#2-Analysis: Generates main and appendix figures and tables
*--------------------------------------------------------------

*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%	
*0. Set preliminaries and directory definitions and run startup files.
*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%
	/* Action required: Change to path to the replication folder on your home directory. */
	* set directory paths
	global home "~/Dropbox/wage_norms/qje_revision1"
	
	* Action required: Install packages 
	ssc install reghdfe, replace
	ssc install ivreg2, replace
	ssc install estout, replace
	ssc install maptile, replace
	ssc install spmap, replace
	ssc install statastates, replace
	ssc install mdesc, replace
	ssc install rsource, replace
	ssc install ftools, replace
	ssc install distinct, replace
	ssc install matsave, replace
	ssc install keeporder, replace
	ssc install parmest, replace
	ssc install shp2dta, replace
	ssc install ivreghdfe, replace
	ssc install geoinpoly, replace
	maptile_install using "http://files.michaelstepner.com/geo_cz1990.zip", replace	

	* Install ftools (remove program if it existed previously)
	cap ado uninstall ftools
	net install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/") replace

	* Install reghdfe
	cap ado uninstall reghdfe
	net install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/") replace

	* Install ivreg2, the core package
	cap ado uninstall ivreg2
	ssc install ivreg2, replace

	* Finally, install this package
	cap ado uninstall ivreghdfe
	net install ivreghdfe, from("https://raw.githubusercontent.com/sergiocorreia/ivreghdfe/master/src/") replace
		
	* Code
	global code				"$home/replication/code"
	global programs         "$code/programs"

	* Data: Note data are not included in this package due to DUA terms.
	global data 			"$home/data"
	global minwage			"$data/minimum_wages"
	global unemp			"$data/unemp_rate"
	global crosswalks       "$data/crosswalks"
	
	* Figures and Tables
	global figures_tables 	"$home/code_replication/figures_tables"
	
	* Set colors
	global dnwblue "5 50 142"
	global dnwbrown "118 60 2"
	global dnwcrimson "114 0 23"
	global dnwdkbrown "39 1 1"
	global dnwgold "217 172 42"
	global dnwltgold "216 213 131"
	global dnwmdbrown "142 92 29"
	
	#d ;
	cap log close; cap program drop _all; clear all; version 13.1; set matsize 11000; set maxvar 120000; set more off; set seed 1003;
	cd "${code}"; run "programs/Startup"; macro dir;
	#d cr	
	
	cd "${code}"

	* Uncomment below to run the code
/*
*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%	
*1. Build.
*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%

log using "StartTime.txt", text replace
display "`c(current_date)', `c(current_time)'"
log close

do 1a_minimum_wage_policy_data.do		
do 1b_qcew_data.do				
do 1c_cps_org_clean.do			
do 1d_store_locations.do			
do 1e_cb_clean_firm_data.do
do 1f_cb_create_stacked_dataset.do
do 1g_cb_cps_summary_stats_data.do
do 1h_clean_bunching_analysis_dataset.do

*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%	
*2a. Analyze.
*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%
log using "StartTime.txt", text replace
display "`c(current_date)', `c(current_time)'"
log close

do 2a_fig1_us_mw_vmw_figa1_a2_taba1.do
do 2b_tab1_summary_stats.do
do 2c_fig2_wage_distribution_15vmw_figb1_b2_tabb1_b7.do
do 2d_fig3_own_gap_distribution_tabb8_figf1_f4_emp_share_sg_distribution_figd4.do
do 2e_fig4_own_wage_15_fig5_own_emp_15_figc1_c6.do
do 2f_tab2_own_effects_tabc1_c2.do
do 2g_figd1_tabd1_d4.do
do 2h_fig6_average_wages_policy_nonpolicy_figd2_d3.do
do 2i_tab3_hiring_composition_effects.do
do 2j_fig5d_tab4_5_market_poaching_effects.do
do 2k_fig7_8_spillover_wage_15_figd6_d7.do

*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%	
*. Run the following files in Python
*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%

* 2l1_bhm_bassier_replication_cwe_theta_eta.py
* 2l2_bhm_bassier_replication_cwe.py

*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%	
*2c. Analyze.
*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------%
do 2l_tab6_9_spillover_effects_tabd6_d13.do
do 2m_tab10_qcew_spillover_effects.do
do 2n_figd8_d10_spillover_wage_15_npgap.do
do 2o_fig9_10_cw_elasticities_literature_figf5_bassier.do
do 2p_figd11_13_bunching_analysis.do

*/
